#include "StdAfx.h"

TradeSystem::TradeSystem(void) { }
TradeSystem::TradeSystem(double stopLoss, double stopGain)
{
	this->_stopLossPoint = stopLoss;
	this->_stopGainPoint = stopGain;
	this->_buyPrice = 0;
	this->_sellPrice = 0;
	this->_coverPrice = 0;
	this->_shortPrice = 0;
}

TradeSystem::~TradeSystem(void) { }

double TradeSystem::ApplyStop(bool stopGain, double basePrice, double tradePrice)
{
	double stopPrice;

	if(stopGain) {
		if (this->_stopGainPoint > 0) {
			stopPrice = basePrice * (1 + this->_stopGainPoint);
			return (tradePrice >= stopPrice) ? stopPrice : 0;
		}
	}
	else if (this->_stopLossPoint > 0) {
		stopPrice = basePrice * (1 - this->_stopLossPoint) ;
		return (tradePrice <= stopPrice) ? stopPrice : 0;
	}

	return 0;
}

bool TradeSystem::CrossAbove(vector<double> *vet1, vector<double> *vet2)
{
	return false;
}
